#!/usr/bin/env python

import sys
sys.path.append("c:\\Data\\python")
sys.path 
import pcapy
from pcapy import *

devs = pcapy.findalldevs()
print "Devices List :"
for i in devs:
    print "<%s>Dev:%s,Network:%s" %(devs.index(i),i,pcapy.open_live(i,0,0,0).getnet())
devIndex = raw_input("Your choice : ")
dev = devs[int(devIndex)]
obj = pcapy.open_live(dev,1500,0,100)
newfile = 'mm.pcap'
dumper = obj.dump_open(newfile)
print "Listening on %s" %dev
def pk(hdr, data):
    print "capture:%s" %data
    dumper.dump(hdr, data)
try:
    obj.loop(0,pk)
except KeyboardInterrupt:
    print "Terminated by user !"
    sys.exit(0)

